1. Field of the Invention
The invention generally relates to the field of digital communication, and particularly relates to the parsing of packets from a data stream.
2. Description of the Related Art
Digital data are generally transmitted in contiguous groups called packets. A packet in a data stream typically starts with a number of bits called a header that provides information on the packet's characteristics such as its length, the type of data it carries, and perhaps error-checking information and the destination of the data, among other characteristics. The header of a data packet is typically followed by a payload section of data, which comprises the data to be communicated by the packet. The packetization of data provides several advantages. Primary among these is the robustness of the data transfer. The finite length packets are typically independent of each other, therefore, errors in one packet do not propagate to cause errors in data from other packets. Packetization also permits multiplexing, allowing multiple users to share a single communications resource. This flexibility also allows a single data stream to carry more than one type of data. For example, some data formats in common use for the transfer of video and audio information are the NPEG standard formats (such as MPEG-1 and MPEG-2) defined by the Moving Picture Experts Group, a working group of ISO.
FIG. 1: Packetized data stream
FIG. 1 shows a sample data stream comprising audio and video packets from an MPEG data stream. Although this discussion particularly describes an MPEG data stream, the structure described in this figure is equally applicable to other interlaced digital data formats.
As shown in the figure, a packetized elementary stream (PES) 100 comprises a stream of audio and video PES packets. The PES data stream is thus a single data stream comprising two interlaced elementary streams (ES): an audio ES and a video ES. The PES stream comprises a series of audio PES packets and video PES packets. Each audio PES packet comprises a header portion and an audio data portion, and each video PES packet comprises a header portion and a video data portion. When read in sequence, the audio data portions can be recombined into the audio elementary stream 110. Similarly, the video data portions can be read in sequence and recombined into the video elementary stream 120. Although only two types of elementary streams (audio and video) are shown in this figure, the MPEG-2 specification provides for four different types of PES packets: MPEG video (a compressed video format), MPEG audio (a compressed audio format), private stream 1, and private stream 2. The two private streams allow the MPEG-2 definition to be used in specialized systems that communicate information other than the standard MPEG audio and video. Each of the four types of PES packets has a predefined format for its header. A parameter in the PES header, called the stream_id, identifies the packet as being one of these four types of PES packet. Thus by reading the stream_id from the PES packet header, a receiving unit may rapidly identify which type of packet is being received in the data stream, and respond accordingly. For example, in the case of an audio-video decoder that does not use the private stream 1 or private stream 2 information, a parser in the decoder may read the headers of each PES packet received in the data stream, and after identifying the packet according to its stream_id, direct the payload data so that video data portions are sent to a video buffer, audio data portions are sent to an audio buffer, and private stream 1 and private stream 2 data are discarded.
A particular technology using the MPEG-2 data format is the digital versatile disk (DVD) for optical disk storage technology. DVD storage systems have widespread use in the storage and communication of audio and video data, particularly in home entertainment use. In addition to holding MPEG audio and video, the DVD standard specifies formats other types of information, such as other types of audio streams, sub-picture information for display at the bottom of the video screen, and navigation information to enable interactive usage. These other types of information are also transferred in packets in the MPEG 2 data stream, interleaved with the MPEG audio and MPEG video data packets. The additional data are placed in custom packets of various types. There are custom data packets for Dolby AC-3 audio, DTS audio, SDDS audio, linear PCM audio, PCI data, and DSI data. In addition, other types of custom data packets are reserved for future use, such as extended sub-picture data. All these different types of custom data packets must be formatted into either private stream 1 or private stream 2 data packets to be included in an MPEG-2 PES. To distinguish among these various types of data packets, identifying information on them is included in the beginning of each data portion of the private stream data packets. This identifying information, though it is included in the data portion of the packet, effectively comprises an additional header portion for the private stream 1 and private stream 2 data packets in the DVD specification.
FIG. 2: AC-3 audio packet in a DVD data stream
An example of such a custom data packet is shown in FIG. 2. As described earlier, the first part of the packet is a private stream 1 packet header 251, and the following information is the private stream 1 data 252. The private stream 1 packet header 251 comprises a number of fields. The first field is the "packet_start_code_prefix" 201, a predefined 24 bit sequence of 23 0's followed by a trailing 1 (or in hexadecimal: 00 0001h). This unique sequence identifies the start of a PES packet, whether the PES packet is an MPEG audio, MPEG video, private stream 1 or private stream 2 packet. The next field is the stream_id 202. As shown in the following table, the stream_id uniquely identifies which of the four types of MPEG 2 packets is being received. Note that in this discussion, a number with suffix "h" is a hexadecimal number, while a "b" suffix indicates a binary number.
stream_id Stream coding 110x 0nnnb MPEG audio stream (for Decoding Audio stream number nnn) 1110 0000b Video stream 1011 1101b private_stream_1 1011 1111b private_stream_2
By way of example, FIG. 2 shows the stream_id 202 to be the binary number 1011 1101b, indicating that the packet is a private stream 1 packet. The field following the stream_id 202 is the "PES_packet-length" 203, which indicates the total length of the PES packet. The following two bytes in the private stream 1 header comprise various flags 204 describing the packet. Following these flags is the "PES_header_data_length" 205, which indicates the number of remaining bytes before the end of the PES header. This field is a one byte field, so in principle between 0 and 255 bytes may remain in the packet header. According to the DVD specification, however, between 8 and 15 further bytes of data would be included at the end 206 of the header for this packet. After the last byte of the private stream 1 packet header begin the private stream 1 data bytes. Note that the private stream 1 packet header has identified the packet as being a private stream 1 packet. There has been no indication in the header 251, however, of the type of data to be carried in the payload of the packet. This identification is carried in the first byte of the private stream 1 data 252: the "sub_stream_id" field 210. The sub_stream_id 210, along with other payload description at the beginning of the private stream 1 data portion 252 effectively make up a sub header 253 of additional information for the private stream 1 sub-packet.
By way of example, FIG. 2 shows a data packet carrying Dolby AC-3 audio data. Thus the one-byte sub-stream_id 210 for this field would be in the range between the hexadecimal numbers 80h and 87h, corresponding to a binary number of 10000 nnnb. The last three bits of this number represent a number between 0 and 7: the audio stream number for this audio packet. (The DVD specification allows for the interleaving of multiple alternative video tracks and multiple alternative audio tracks. Thus, a user may choose between several views for a given scene, and between several choices of audio track to accompany the scene, such as an English track, a Spanish track, or a music track, for example. The audio stream number indicates which of the eight audio streams is being carried in the current packet.)
The following table indicates some of the designated sub-stream packets and their stream_id/sub_stream_id identifiers.
 stream_id sub_stream_id Stream coding private_stream_1 1011 1101b 001* ****b Sub-picture stream (******=Decoding Sub-picture stream number) 1011 1101b 011* ****b Reserved (for extended Sub-picture) 1011 1101b 1000 0***b Dolby AC-3 audio stream (***=Decoding Audio stream number) 1011 1101b 1000 1***b DTS audio stream (***=Decoding Audio stream number) 1011 1101b 1001 0***b SDDS audio stream (***=Decoding Audio stream number) 1011 1101b 1010 0***b Linear PCM audio stream (***=Decoding Audio stream number) private_stream_2 1011 1111b 0000 0000b PCI stream 1011 1111b 0000 0001b DSI stream
In a DVD data stream, the sub_stream_id field 210 is the first byte of the data field in all private stream 1 and private stream 2 packets. The next two fields shown in FIG. 2 are particular to the AC-3 packets. Other header information may be present for other types of packets. The AC-3 fields of "number_of_frames_headers" 211 and "first_access_unit_pointer" 212 indicate the number of AC-3 frames contained in the AC-3 payload and the location of the start of the first AC-3 packet in the payload. Following these two fields is a block of data 254 carrying the payload AC-3 data.
As can be seen from the above discussion, if a received packet is an MPEG audio or MPEG video packet, its identity can be determined by looking at the fourth byte of the packet: the stream_id. However, for the other types of packet received in a DVD stream, the identity of the packet is not determined until the sub_stream_id byte is received. Both of these bytes are required to identify of the packet, but as can be seen in FIG. 2, they may be separated by as much as 260 intervening bytes.
This structure poses challenges for the handling of incoming data. If all of the data in an incoming packet header are to be interpreted before the purpose of the packet is ascertained, a large amount of computational power will be expended on the processing of unnecessary packets, since a data stream may comprise packets for audio streams, video streams, and other information that are not used by a particular receiver. For example, if a receiver is using a Spanish audio track to accompany a video track, it is not necessary for the receiver to process the packets for a received French audio track. It would be most efficient to quickly recognize such unnecessary packets and discard them without further processing. Thus, it would be useful to have a means for rapidly determining the identity of an incoming DVD packet before initiating processing of the packet's header data.
Another challenge imposed by the DVD data structure is the management of the various data streams. The DVD stream is typically parsed by logic components on a DVD processor chip and provided to an off-chip memory storage, such as a DRAM. This off-chip memory provides a buffer region for the various data streams which are then read separately back into the DVD processor chip for decoding and forwarding to the appropriate output units such as stereo systems and TV monitors. Some amount of memory is required on the DVD processing chip to buffer the parsed data streams before they are shipped to the off-chip memory. This on-chip memory is at a premium because it requires a large amount of "real estate" on the chip. Large on-chip memories can greatly increase the production cost a DVD processor, so efficient use of on-chip memory for rapid data-stream parsing would provide a DVD chip with practical and valuable advantages.